package com.ctakit.sdk.view;

import android.view.View;

import java.lang.reflect.Method;

final class EventListenerManager {

    public enum ClickMethod {
        Click, LongClick, ItemClick, itemLongClick
    }


    public static void addEventMethod(
            //根据页面或view holder生成的ViewFinder
            ViewFinder finder,
            //根据当前注解ID生成的ViewInfo
            ViewInfo info,
            //事件方法
            ClickMethod clickMethod,
            //页面或view holder对象
            Object handler,
            //当前注解方法
            Method method) {
        try {
            View fieldView = finder.find(info.value);
            if (fieldView !=null) {
                ((View) fieldView).setOnClickListener(new EventListener(handler).click(method.getName()));
            }
        } catch (Throwable ex) {

        }
    }





}
